package org.study.spring.service.impl;

import java.util.Map;

import org.quincy.rock.core.dao.SQLProvider;
import org.quincy.rock.core.dao.sql.Sort;
import org.quincy.rock.core.vo.PageSet;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.study.spring.AppUtils;
import org.study.spring.BaseService;
import org.study.spring.dao.OrderDao;
import org.study.spring.entity.Order;
import org.study.spring.entity.Photo;
import org.study.spring.service.OrderService;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

@Service
public class OrderServiceImpl extends BaseService<Order, OrderDao> implements OrderService {



	@Override
	public PageSet<Order> queryPageByCondition(Map<String, Object> condition, Sort sort, int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);
		PageHelper.orderBy(sort.toString(SQLProvider.getFieldNameConverter()));
		Page<Order> p = this.operate().findPageByCondition(condition);
		return AppUtils.toPageSet(p);
	}


	

	

	@Override
	public Photo getPhoto(long id) {
		return this.operate().getPhoto(id);
	}

	@Override
	@Transactional
	public int updatePhoto(Photo photo) {
		return operate().updatePhoto(photo);
	}

	@Override
	@Transactional
	public int updateSelfInfo(Order vo) {
		return operate().updateSelfInfo(vo);
	}

	/** 
	 * insert。
	 * @see org.teach.study.boot.BaseService#insert(org.teach.study.boot.Entity, boolean)
	 */
	@Override
	@Transactional
	public int insert(Order entity, boolean ignoreNullValue) {
		
		
		return super.insert(entity, ignoreNullValue);
	}







	@Override
	public Order findByCode(String code) {
		return operate().findByCode(code);
	}
}
